package org.gap.domain;

import java.io.Serializable;

import java.lang.StringBuilder;

import java.util.Calendar;
import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

import javax.xml.bind.annotation.*;

import javax.persistence.*;

/**
 */

@Entity
@NamedQueries({
		@NamedQuery(name = "findAllPatients", query = "select myPatient from Patient myPatient"),
		@NamedQuery(name = "findPatientByPatAxeMedical", query = "select myPatient from Patient myPatient where myPatient.patAxeMedical = ?1"),
		@NamedQuery(name = "findPatientByPatAxeMedicalContaining", query = "select myPatient from Patient myPatient where myPatient.patAxeMedical like ?1"),
		@NamedQuery(name = "findPatientByPatDateDerniereVisite", query = "select myPatient from Patient myPatient where myPatient.patDateDerniereVisite = ?1"),
		@NamedQuery(name = "findPatientByPatDateDerniereVisiteAfter", query = "select myPatient from Patient myPatient where myPatient.patDateDerniereVisite > ?1"),
		@NamedQuery(name = "findPatientByPatDateDerniereVisiteBefore", query = "select myPatient from Patient myPatient where myPatient.patDateDerniereVisite < ?1"),
		@NamedQuery(name = "findPatientByPatDateEntree", query = "select myPatient from Patient myPatient where myPatient.patDateEntree = ?1"),
		@NamedQuery(name = "findPatientByPatDateEntreeAfter", query = "select myPatient from Patient myPatient where myPatient.patDateEntree > ?1"),
		@NamedQuery(name = "findPatientByPatDateEntreeBefore", query = "select myPatient from Patient myPatient where myPatient.patDateEntree < ?1"),
		@NamedQuery(name = "findPatientByPatDateSortie", query = "select myPatient from Patient myPatient where myPatient.patDateSortie = ?1"),
		@NamedQuery(name = "findPatientByPatDateSortieAfter", query = "select myPatient from Patient myPatient where myPatient.patDateSortie > ?1"),
		@NamedQuery(name = "findPatientByPatDateSortieBefore", query = "select myPatient from Patient myPatient where myPatient.patDateSortie < ?1"),
		@NamedQuery(name = "findPatientByPatDiagnostic", query = "select myPatient from Patient myPatient where myPatient.patDiagnostic = ?1"),
		@NamedQuery(name = "findPatientByPatDiagnosticContaining", query = "select myPatient from Patient myPatient where myPatient.patDiagnostic like ?1"),
		@NamedQuery(name = "findPatientByPatDivers", query = "select myPatient from Patient myPatient where myPatient.patDivers = ?1"),
		@NamedQuery(name = "findPatientByPatDiversContaining", query = "select myPatient from Patient myPatient where myPatient.patDivers like ?1"),
		@NamedQuery(name = "findPatientByPatMotifSortie", query = "select myPatient from Patient myPatient where myPatient.patMotifSortie = ?1"),
		@NamedQuery(name = "findPatientByPatMotifSortieContaining", query = "select myPatient from Patient myPatient where myPatient.patMotifSortie like ?1"),
		@NamedQuery(name = "findPatientByPatPatient", query = "select myPatient from Patient myPatient where myPatient.patPatient = ?1"),
		@NamedQuery(name = "findPatientByPatSousAxeMedical", query = "select myPatient from Patient myPatient where myPatient.patSousAxeMedical = ?1"),
		@NamedQuery(name = "findPatientByPatSousAxeMedicalContaining", query = "select myPatient from Patient myPatient where myPatient.patSousAxeMedical like ?1"),
		@NamedQuery(name = "findPatientByPatTelContact", query = "select myPatient from Patient myPatient where myPatient.patTelContact = ?1"),
		@NamedQuery(name = "findPatientByPrimaryKey", query = "select myPatient from Patient myPatient where myPatient.patPatient = ?1") })
@Table(schema = "GAP", name = "PATIENT")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "GAP_v2/org/gap/domain", name = "Patient")
@XmlRootElement(namespace = "GAP_v2/org/gap/domain")
public class Patient implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 */

	@Column(name = "PAT_PATIENT", nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@Id
	@XmlElement
	Integer patPatient;
	/**
	 */
	@Temporal(TemporalType.DATE)
	@Column(name = "PAT_DATE_ENTREE")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	Calendar patDateEntree;
	/**
	 */

	@Column(name = "PAT_TEL_CONTACT", nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	Integer patTelContact;
	/**
	 */

	@Column(name = "PAT_DIVERS", length = 50, nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String patDivers;
	/**
	 */
	@Temporal(TemporalType.DATE)
	@Column(name = "PAT_DATE_SORTIE")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	Calendar patDateSortie;
	/**
	 */

	@Column(name = "PAT_AXE_MEDICAL", length = 25, nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String patAxeMedical;
	/**
	 */

	@Column(name = "PAT_SOUS_AXE_MEDICAL", length = 25, nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String patSousAxeMedical;
	/**
	 */

	@Column(name = "PAT_MOTIF_SORTIE", length = 30, nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String patMotifSortie;
	/**
	 */

	@Column(name = "PAT_DIAGNOSTIC", length = 40, nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String patDiagnostic;
	/**
	 */
	@Temporal(TemporalType.DATE)
	@Column(name = "PAT_DATE_DERNIERE_VISITE")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	Calendar patDateDerniereVisite;

	/**
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumns({ @JoinColumn(name = "PAT_TIERS", referencedColumnName = "TIE_TIERS", nullable = false) })
	@XmlTransient
	Tiers tiers;
	/**
	 */
	@OneToMany(mappedBy = "patient", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)
	@XmlElement(name = "", namespace = "")
	java.util.Set<org.gap.domain.RendezVous> rendezVouses;

	/**
	 */
	public void setPatPatient(Integer patPatient) {
		this.patPatient = patPatient;
	}

	/**
	 */
	public Integer getPatPatient() {
		return this.patPatient;
	}

	/**
	 */
	public void setPatDateEntree(Calendar patDateEntree) {
		this.patDateEntree = patDateEntree;
	}

	/**
	 */
	public Calendar getPatDateEntree() {
		return this.patDateEntree;
	}

	/**
	 */
	public void setPatTelContact(Integer patTelContact) {
		this.patTelContact = patTelContact;
	}

	/**
	 */
	public Integer getPatTelContact() {
		return this.patTelContact;
	}

	/**
	 */
	public void setPatDivers(String patDivers) {
		this.patDivers = patDivers;
	}

	/**
	 */
	public String getPatDivers() {
		return this.patDivers;
	}

	/**
	 */
	public void setPatDateSortie(Calendar patDateSortie) {
		this.patDateSortie = patDateSortie;
	}

	/**
	 */
	public Calendar getPatDateSortie() {
		return this.patDateSortie;
	}

	/**
	 */
	public void setPatAxeMedical(String patAxeMedical) {
		this.patAxeMedical = patAxeMedical;
	}

	/**
	 */
	public String getPatAxeMedical() {
		return this.patAxeMedical;
	}

	/**
	 */
	public void setPatSousAxeMedical(String patSousAxeMedical) {
		this.patSousAxeMedical = patSousAxeMedical;
	}

	/**
	 */
	public String getPatSousAxeMedical() {
		return this.patSousAxeMedical;
	}

	/**
	 */
	public void setPatMotifSortie(String patMotifSortie) {
		this.patMotifSortie = patMotifSortie;
	}

	/**
	 */
	public String getPatMotifSortie() {
		return this.patMotifSortie;
	}

	/**
	 */
	public void setPatDiagnostic(String patDiagnostic) {
		this.patDiagnostic = patDiagnostic;
	}

	/**
	 */
	public String getPatDiagnostic() {
		return this.patDiagnostic;
	}

	/**
	 */
	public void setPatDateDerniereVisite(Calendar patDateDerniereVisite) {
		this.patDateDerniereVisite = patDateDerniereVisite;
	}

	/**
	 */
	public Calendar getPatDateDerniereVisite() {
		return this.patDateDerniereVisite;
	}

	/**
	 */
	public void setTiers(Tiers tiers) {
		this.tiers = tiers;
	}

	/**
	 */
	public Tiers getTiers() {
		return tiers;
	}

	/**
	 */
	public void setRendezVouses(Set<RendezVous> rendezVouses) {
		this.rendezVouses = rendezVouses;
	}

	/**
	 */
	public Set<RendezVous> getRendezVouses() {
		if (rendezVouses == null) {
			rendezVouses = new java.util.LinkedHashSet<org.gap.domain.RendezVous>();
		}
		return rendezVouses;
	}

	/**
	 */
	public Patient() {
	}

	/**
	 * Copies the contents of the specified bean into this bean.
	 *
	 */
	public void copy(Patient that) {
		setPatPatient(that.getPatPatient());
		setPatDateEntree(that.getPatDateEntree());
		setPatTelContact(that.getPatTelContact());
		setPatDivers(that.getPatDivers());
		setPatDateSortie(that.getPatDateSortie());
		setPatAxeMedical(that.getPatAxeMedical());
		setPatSousAxeMedical(that.getPatSousAxeMedical());
		setPatMotifSortie(that.getPatMotifSortie());
		setPatDiagnostic(that.getPatDiagnostic());
		setPatDateDerniereVisite(that.getPatDateDerniereVisite());
		setTiers(that.getTiers());
		setRendezVouses(new java.util.LinkedHashSet<org.gap.domain.RendezVous>(that.getRendezVouses()));
	}

	/**
	 * Returns a textual representation of a bean.
	 *
	 */
	public String toString() {

		StringBuilder buffer = new StringBuilder();

		buffer.append("patPatient=[").append(patPatient).append("] ");
		buffer.append("patDateEntree=[").append(patDateEntree).append("] ");
		buffer.append("patTelContact=[").append(patTelContact).append("] ");
		buffer.append("patDivers=[").append(patDivers).append("] ");
		buffer.append("patDateSortie=[").append(patDateSortie).append("] ");
		buffer.append("patAxeMedical=[").append(patAxeMedical).append("] ");
		buffer.append("patSousAxeMedical=[").append(patSousAxeMedical).append("] ");
		buffer.append("patMotifSortie=[").append(patMotifSortie).append("] ");
		buffer.append("patDiagnostic=[").append(patDiagnostic).append("] ");
		buffer.append("patDateDerniereVisite=[").append(patDateDerniereVisite).append("] ");

		return buffer.toString();
	}

	/**
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = (int) (prime * result + ((patPatient == null) ? 0 : patPatient.hashCode()));
		return result;
	}

	/**
	 */
	public boolean equals(Object obj) {
		if (obj == this)
			return true;
		if (!(obj instanceof Patient))
			return false;
		Patient equalCheck = (Patient) obj;
		if ((patPatient == null && equalCheck.patPatient != null) || (patPatient != null && equalCheck.patPatient == null))
			return false;
		if (patPatient != null && !patPatient.equals(equalCheck.patPatient))
			return false;
		return true;
	}
}
